<#include "/layout/layout.ftl">
<#import "/layout/macro.ftl" as macro>
<#import "/layout/select.ftl" as my/>
<#assign css>
<#--此ftl中用到的css-->
</#assign>
<#assign js>
<#--此ftl中用到的js-->
    <script>
        $(".btn-submit").click(function () {
            // 校验表单合法
            var bootstrapValidator = $(".form-edit").data('bootstrapValidator');
            bootstrapValidator.validate();
            if (bootstrapValidator.isValid()) {
                $.ajax({
                    type: "POST",
                    url: "/partner/edit",
                    data: $(".form-edit").serialize(),
                    dataType: "JSON",
                    success: function (res) {
                        layer.msg(res.message, {
                            time: 2000
                        }, function () {
                            location.href = "/partner/index";
                        });
                    }
                });
            } else {
                return false;
            }
        });

        $('.form-edit').bootstrapValidator({
            message: '请输入有效值',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            }
        });

    </script>
</#assign>
<@layout title="编辑" active="partner">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            编辑
            <small>商家详细信息</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="/"><i class="fa fa-home"></i> 管理后台</a></li>
            <li><a href="/partner/index"><i class="fa fa-list-ul"></i> 合作商家管理</a></li>
            <li class="active"><i class="fa fa-edit"></i>
                编辑
            </li>
        </ol>
    </section>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <!-- Default box -->
                <div class="box  box-primary">
                    <form class="form-horizontal form-edit" method="post" action="partner/edit">
                        <div class="box-body">
                            <input type="hidden" id="id" name="id" value="${user.id!}">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">合作商家名称：</label>
                                <div class="col-sm-10">
                                    <input disabled required placeholder="请输入" id="partnerName" name="partnerName"
                                           class="form-control" type="text" value="${user.partnerName!}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">合作商家地址：</label>
                                <div class="col-sm-10">
                                    <input disabled required placeholder="请输入" id="partnerAddress" name="partnerAddress"
                                           class="form-control" type="text" value="${user.partnerAddress!}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">合作商家电话：</label>
                                <div class="col-sm-10">
                                    <input disabled required placeholder="请输入" id="partnerPhone" name="partnerPhone"
                                           class="form-control" type="text" value="${user.partnerPhone!}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">地址纬度：</label>
                                <div class="col-sm-10">
                                    <input disabled required placeholder="请输入" id="partnerLatitude" name="partnerLatitude"
                                           class="form-control" type="text" value="${user.partnerLatitude!}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">地址经度：</label>
                                <div class="col-sm-10">
                                    <input disabled required placeholder="请输入" id="partnerLongitude" name="partnerLongitude"
                                           class="form-control" type="text" value="${user.partnerLongitude!}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">合作商家文案：</label>
                                <div class="col-sm-10">
                                    <textarea required id="partnerRemark" name="partnerRemark"
                                           class="form-control">${user.partnerRemark!}</textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">合作商家头像：</label>
                                <div class="col-sm-10">
                                    <img src="${user.partnerAvatar!}" style="width: 200px;height: 200px">
                                </div>
                            </div>
                            <#--<div class="form-group">
                                <label class="col-sm-2 control-label">同意合作商家：</label>
                                <div class="col-sm-10">
                                    <@my.select id="isPartner" datas=getDict('IS_NOT')  value="${user.isPartner!}" defaultValue="请选择"/>
                                </div>
                            </div>-->
                            <div class="form-group">
                                <label class="col-sm-2 control-label">单笔基础费用：</label>
                                <div class="col-sm-10">
                                    <input required placeholder="请输入单笔基础费用" id="partnerAmount" name="partnerAmount"
                                           class="form-control" type="text" value="${user.partnerAmount!}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">抽成比例（%）：</label>
                                <div class="col-sm-10">
                                    <input required placeholder="请输入抽成比例" id="partnerScale" name="partnerScale"
                                           class="form-control" type="number" value="${user.partnerScale!}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">合作商家协议：</label>
                                <div class="col-sm-10">
                                    <textarea id="partnerProtocol" name="partnerProtocol"
                                           class="form-control">${user.partnerProtocol!}</textarea>
                                </div>
                            </div>
                            <div class="box-footer">
                                <button type="button" class="btn btn-default btn-back">返回</button>
                                <button type="button" class="btn btn-info pull-right btn-submit">提交</button>
                            </div>

                    </form>
                </div>
                <!-- /.box -->
            </div>
        </div>
    </section>
    <!-- /.content -->
</@layout>
